package com.diamond.smart.info.service.impl;

import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diamond.common.utils.PageUtils;
import com.diamond.common.utils.Query;

import com.diamond.smart.info.dao.DeviceTypeDao;
import com.diamond.smart.info.entity.DeviceTypeEntity;
import com.diamond.smart.info.service.DeviceTypeService;
import org.springframework.util.StringUtils;


@Service("deviceTypeService")
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeDao, DeviceTypeEntity> implements DeviceTypeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<DeviceTypeEntity> wrapper = new QueryWrapper<>();
        if (StringUtils.hasLength((String) params.get("key"))) {
            wrapper.eq("type_id", params.get("key"));
        }
        IPage<DeviceTypeEntity> page = this.page(
                new Query<DeviceTypeEntity>().getPage(params), wrapper
        );

        return new PageUtils(page);
    }

}